#include "texturemanager.h"

GLuint TextureManager::load(std::string image)
{
	SDL_Surface* img = IMG_Load((_RESPATH + image).c_str());
	GLuint id = loadTexture(img);
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	SDL_FreeSurface(img);
	textures[image] = id;
	return id;
}

GLuint TextureManager::get(std::string image)
{
	int id = textures[image];
	if(id == 0)
	{
		return load(image);
	}
	else
	{
		return id;
	}
}

void TextureManager::unload(std::string image)
{
	//   ?
}

TextureManager::~TextureManager()
{
	//   ?
}